package com.dense.kuiniu.bookborrow.business.home.borrow;

import android.app.Activity;
import android.widget.TextView;

import com.blankj.utilcode.util.LanguageUtils;
import com.dense.kuiniu.bookborrow.R;
import com.dense.kuiniu.bookborrow.business.entity.ReaderInfo;

/**
 * @author Administrator
 * @date 2020/8/25
 */
public class ScanUiHelper {
    private Activity mActivity;
    private final TextView mTvName;
    private final TextView mTvCardNo;
    private final TextView mTvBorrowBookCount;
    private final TextView mTvBorrowPeriodicalCount;
    private final TextView mTvState;

    public ScanUiHelper(Activity activity, TextView tvName, TextView tvCardNo,
                        TextView tvBorrowCount, TextView periodicalCount, TextView tvState) {
        mActivity = activity;
        mTvName = tvName;
        mTvBorrowPeriodicalCount = periodicalCount;
        mTvCardNo = tvCardNo;
        mTvBorrowBookCount = tvBorrowCount;
        mTvState = tvState;
    }

    public void setInfo(ReaderInfo info) {
        if (info != null) {
            mTvName.setText(String.format("%s%s", mActivity.getString(R.string.text_user_name), info.getName()));
            mTvCardNo.setText(String.format("%s%s", mActivity.getString(R.string.text_card_no), info.getReaderCode()));
            mTvBorrowBookCount.setText(String.format(LanguageUtils.getCurrentLocale(),
                    "%s%s", "已借数量：",
                    info.getBorrowCount()));
            mTvState.setText(String.format("%s%s", mActivity.getString(R.string.text_state), info.getState()));
        }
    }
}